import 'package:flutter/material.dart';
import 'package:myapp/page/Chat/message_text.dart';
import 'package:myapp/type/chat.dart';

class Message extends StatefulWidget {
  final MessageContent messageContent;
  final String avatar;
  final String myId;
  const Message(
      {super.key,
      required this.messageContent,
      required this.avatar,
      required this.myId});

  @override
  State<StatefulWidget> createState() {
    return _MessageState();
  }
}

class _MessageState extends State<Message> {
  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
        child: Row(
          verticalDirection: VerticalDirection.down,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: const EdgeInsets.only(right: 16),
              child: CircleAvatar(
                radius: 22,
                backgroundImage: NetworkImage(widget.avatar),
              ),
            ),
            Expanded(
              child: DecoratedBox(
                decoration: BoxDecoration(
                  color: Colors.amber,
                  borderRadius: BorderRadius.circular(5),
                ),
                child: SizedBox(
                    child: Padding(
                  padding: const EdgeInsets.all(8),
                  child: MessageText(
                    text: widget.messageContent.content.getProperty('content'),
                  ),
                )),
              ),
            )
          ],
        ));
  }
}
